package com.sh.rbac.domain.vo.user;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.sh.rbac.core.sensitive.annotation.Sensitive;
import com.sh.rbac.core.sensitive.enums.SensitiveStrategy;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 用户视图对象
 * @author wb
 * @since 2025-11-06
 */


@Schema(description = "用户视图对象")
@Data
public class UserVO {

    @Schema(description = "主键")
    private Long id;
    @Schema(description = "部门ID")
    private Long deptId;
    @Schema(description = "用户名")
    private String username;
    @Schema(description = "昵称")
    private String nickname;

    @Sensitive(strategy = SensitiveStrategy.EMAIL, roleKeys = {"ROLE_ADMIN"}, perms = {"sys:user:update"})
    @Schema(description = "邮箱")
    private String email;

    @Sensitive(strategy = SensitiveStrategy.MOBILE_PHONE, roleKeys = {"ROLE_ADMIN"}, perms = {"sys:user:update"})
    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "性别;0-未知,1-男,2-女")
    private Integer sex;
    @Schema(description = "头像")
    private String avatar;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "最后登录时间")
    private LocalDateTime lastLoginTime;

    @Schema(description = "状态;0-正常,1-停用")
    private Integer status;

    @Schema(description = "优先级")
    private Integer priority;

    @Schema(description = "备注")
    private String remark;

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "角色ID集合")
    private List<Long> roleIds;
}
